package cn.hrlly.tao2shou.biz;

import com.zhy.http.okhttp.OkHttpUtils;

import cn.hrlly.tao2shou.other.Config;
import cn.hrlly.tao2shou.callback.OperateOrderCallback;
import cn.hrlly.tao2shou.domain.Orders;
import cn.hrlly.tao2shou.listener.OnOperateOrderListener;

/**
 * User: gengliang
 * Date: 2016-01-31
 * Time: 18:56
 */

public class OperateOrderBizImpl implements OperateOrderBiz {

    private OnOperateOrderListener onOperateOrderListener;

    public OperateOrderBizImpl(OnOperateOrderListener onOperateOrderListener) {
        this.onOperateOrderListener = onOperateOrderListener;
    }

    @Override
    public void cancelUnfinishOrder(Orders orders) {
        OkHttpUtils
                .post()
                .url(Config.key_url)
                .addParams(Config.key_action,Config.action_cancel_unfinish_order)
                .addParams(Config.key_order_id,orders.getOrderId())
                .build()
                .execute(new OperateOrderCallback(onOperateOrderListener));
    }

    @Override
    public void confirmCancelUnfinishOrder(Orders orders) {
        OkHttpUtils
                .post()
                .url(Config.key_url)
                .addParams(Config.key_action,Config.action_confirm_cancel_unfinish_order)
                .addParams(Config.key_order_id,orders.getOrderId())
                .build()
                .execute(new OperateOrderCallback(onOperateOrderListener));
    }

    @Override
    public void cancelCompletedOrder(Orders orders) {
        OkHttpUtils
                .post()
                .url(Config.key_url)
                .addParams(Config.key_action,Config.action_cancel_completed_order)
                .addParams(Config.key_order_id,orders.getOrderId())
                .build()
                .execute(new OperateOrderCallback(onOperateOrderListener));
    }
}
